package recordswipetime

import (
	"github.com/gin-gonic/gin"
	"go-interview-forum/resp"
	"go-interview-forum/service/recordswipetime"
	"strconv"
)

func CreateRecordSwipeTime(c *gin.Context) {
	userId, exists := c.Get("userId")
	if !exists {
		resp.ServerErrorResp(c, resp.SERVER_ERR, "系统错误")
		return
	}

	UserId, err := strconv.Atoi(userId.(string))
	if err != nil {
		resp.ServerErrorResp(c, resp.SERVER_ERR, "系统错误")
		return
	}

	var data = make(map[string]interface{})

	err = c.ShouldBind(&data)
	if err != nil {
		resp.ServerErrorResp(c, resp.SERVER_ERR, err.Error())
		return
	}

	err = recordswipetime.CreateRecordSwipeTime(UserId, data)
	if err != nil {
		resp.ServerErrorResp(c, resp.SERVER_ERR, err.Error())
		return
	}

	resp.SuccessResp(c, nil)

}
